<%--
  Created by IntelliJ IDEA.
  User: xierongxian
  Date: 2016/3/31
  Time: 16:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>

<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>用户验证</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <!-- <link rel="shortcut icon" href="/favicon.ico"> -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="<%=basePath %>/resources/Public/Vendor/SUI/dist/css/sm.min.css">

    <link rel="stylesheet" href="<%=basePath %>/resources/Public/Vendor/SUI/dist/css/sm.min.css">
    <link rel="stylesheet" href="<%=basePath %>/resources/Public/Vendor/SUI/dist/css/sm-extend.min.css">
    <link rel="stylesheet" type="text/css" href="<%=basePath %>/resources/Public/Vendor/icon/iconfont.css">

    <link rel="stylesheet" href="<%=basePath %>/resources/Public/css/common.css">

</head>
<body>
<div class="page-group">

    <div class="page xgj-reg" id='xgj-reg'>
        <div class="content ">
            <div class="list-block">
                <ul>
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">手机号</div>
                                <div class="item-input">
                                    <input type="number" value="" id="phone" placeholder="手机号">
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label yzm">验证码</div>
                                <div class="item-input">
                                    <div class="row no-gutter">
                                        <div class="col-60">
                                            <input type="text" id="value" class="bnt-yzm-val" placeholder="验证码">
                                            <input type="hidden" value="${openid}" id="openid">
                                        </div>
                                        <div class="col-40 "><button onclick="sendSC()"  class="pull-right button button-round btn-yzm btn-code">获取验证码</button></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="content-block">
                <p><a href="javascript:login()" class="button btn-reg-confim btn-reg">确 定</a></p>
            </div>
        </div>


    </div>
</div>



<script src='<%=basePath %>/resources/Public/Vendor/SUI/dist/js/zepto.js'></script>
<script type="text/javascript">
    $.config = {
        // 路由功能开关过滤器，返回 false 表示当前点击链接不使用路由
        routerFilter: function($link) {
            // 某个区域的 a 链接不想使用路由功能
            if ($link.is('.disable-router a')) {
                return false;
            }
            return true;
        }
    };
</script>
<script src='<%=basePath %>/resources/Public/Vendor/SUI/dist/js/sm.js'></script>
<script src='<%=basePath %>/resources/Public/Vendor/SUI/dist/js/sm-city-picker.min.js' ></script>
<script src='<%=basePath %>/resources/Public/Vendor/SUI/dist/js/sm-extend.min.js'></script>
<script src='<%=basePath %>/resources/Public/js/common.js'></script>





<script type="text/javascript">
    $.init();
    function login() {
        $.ajax({
            url: "<%=path%>/wx/user/login.do",
            method: 'GET',
            dataType: 'json',
            data: {
                phone: $('#phone').val(),
                value: $('#value').val(),
                openid: $('#openid').val()
            },
            success: function (data) {
                if (data.result == "0000") {
                    window.location.href = '<%=basePath %>wx/user/center.do';
                } else {
                    $.toast(data.msg);
                }

            }
        });
    }
    function sendSC(){
        if($('#phone').val()==""){
            $.toast("手机号不能为空");
            return;
        }
        $.ajax({
            url: "<%=path%>/wx/user/sendSC.do",
            method: 'GET',
            dataType: 'json',
            data: {
                phone: $('#phone').val(),
                openid:$("#openid").val()
            },
            success: function(data){
                if(data.result=="0000"){
                    $.toast("验证码发送成功");
                }else{
                    $.toast(data.msg);
                }

            },error:function(data){
                alert(data);
            }
        });
    }


</script>



</body>
</html>